package com.example.beryl.UtilActivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.BroadcastReceiver;
import android.content.IntentFilter;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import com.example.beryl.R;
import com.example.beryl.Util.ReceiveBroadCast;


public class UpdateData extends AppCompatActivity {

    private boolean mReceiverTag = false;
    ReceiveBroadCast mBroadcastReceiver = new ReceiveBroadCast();

    @Override
    protected void onResume() {
        super.onResume();
        IntentFilter filter = new IntentFilter();
        mReceiverTag = true;
        filter.addAction("com.android.server.scannerservice.broadcast"); //添加过滤条件，接收广播
        registerReceiver(mBroadcastReceiver, filter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_update_data);
        EditText editText = findViewById(R.id.editText1);
        mBroadcastReceiver.setScanHeadListener(new ReceiveBroadCast.GetCode() {
            @Override
            public void Getcode(String getcode) {
                editText.setText(getcode);
                unregisterReceiver(mBroadcastReceiver);
            }
        });
    }

}